<?php

namespace App\Models\Shop;

use App\Models\BaseModel;

class ShopManager extends BaseModel
{


    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = [
        'created_at','updated_at'
    ];

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    protected $dateFormat = 'U';

    /**
     * 关联用户信息
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user(){
        return $this->belongsTo('App\Models\User\User', 'user_id', 'user_id');
    }

    /**
     * 某店所有的经理数据
     * @param $shop_id
     * @return mixed
     */
    public function allManagers($shop_id){
        $data = $this->withOnly('user', ['user_id', 'nickname', 'cover', 'mobile'])->where('shop_id', $shop_id)->get();
        return $this->after($data);
    }
}
